<?php
/**
  * Mar 13, 2008
  *
  * Coded by: Ropu
  *
  */
include 'login.php';
$hacker = $_SESSION['hacker'];

$fill = array();
$name = $hacker->getName();
$fill['email'] = $hacker->getEmail();
$fill['nickname'] = $hacker->getNickname();
$fill['hackathon'] = $hacker->getHackathonId();
$fill['cv'] = $hacker->getCV();
$fill['work'] = $hacker->getWork();
$fill['extra_info'] = $hacker->getExtraInfo();
 
$saved = false;
$errors = array();

if(isset($_POST['nickname'])) {
  
  include 'classes/fieldsCheck.php';
  $checks = array(array('nickname', 'string', true, 
                                            $lang['myinfo']['nickname_err']),
                  array('email', 'email', true, 
                                            $lang['myinfo']['nickname_err']),
//                  array('hackathon', 'int_positive', true, 
//                                            $lang['myinfo']['hackathon_err']),
                  array('work', 'string', false, 
                                            $lang['myinfo']['work_err']),
                  array('extra_info', 'string', false, 
                                            $lang['myinfo']['extra_info_err']),
                  );
  $fieldsCheck = new FieldsCheck();
  $errors = $fieldsCheck->check($_POST, $checks);
  try {  
     $hackathon = new Hackathon($_POST['hackathon']);
  } catch(Exception $e) {
    $errors['hackathon'] = $lang['myinfo']['hackathon_err'];
  }
  
  if(!count($errors)) {
    $hacker->setEmail($_POST['email']);
    $hacker->setNickname($_POST['nickname']);
    $hacker->setHackathon($_POST['hackathon']);
    $hacker->setWork($_POST['work']);
    $hacker->setExtraInfo($_POST['extra_info']);
    $hacker->save();
    $saved = true;
  }
  
  $fill = $_POST;
}


//  $hacker = new Hacker();
include 'templates/temp_myinfo.php';